import React from "react";
import {Input as AntInput} from "antd";
import PropTypes from "prop-types";
import "./Input.css";

export default class Input extends React.Component {
    render() {
        switch (this.props.type) {
            case "plain":
                return (
                    <AntInput
                        className={"CustomInput"}
                        placeholder={this.props.placeholder}
                        prefix={this.props.prefix}
                        suffix={this.props.suffix}
                        style={this.props.style}
                        value={this.props.value}
                        onChange={this.props.onChange}
                    />
                );
            case "password":
                return (
                    <AntInput.Password
                        className={"CustomInput"}
                        placeholder={this.props.placeholder}
                        prefix={this.props.prefix}
                        suffix={this.props.suffix}
                        style={this.props.style}
                        value={this.props.value}
                        onChange={this.props.onChange}
                    />
                );
            default:
                return null;
        }
    }
}

Input.propTypes = {
    type: PropTypes.oneOf(['plain', 'password']),
    style: PropTypes.object,
    prefix: PropTypes.node,
    suffix: PropTypes.node,
    placeholder: PropTypes.string
};

Input.defaultProps = {
    type: 'plain'
};